/*
 * Assembly.java
 *
 * Created on 05. Juni 2007, 03:13
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package sbc.fact;

import sbc.repos.Board;
import sbc.repos.Unit;
import sbc.repos.Sensor;
import sbc.repos.ModuleFactory;
import corso.lang.*;
/**
 *
 * @author mustermark
 */
public class Assembly extends Task<Object[]> {
    
    public enum State { AVAILABLE, BUSY }
    private State state = State.AVAILABLE;
    private CorsoVarOid boardOid, sensorOneOid, sensorTwoOid;
    
    /**
     * Creates a new instance of Assembly
     */
    public Assembly(String name) {
        super(name);
        boardOid = new CorsoVarOid();
        sensorOneOid = new CorsoVarOid();
        sensorTwoOid  = new CorsoVarOid();
    }
    public Assembly() {}
    
    
    public void workOn(Object[] parts) throws WorkException {
        if(parts.length != 3) throw new WorkException();
        
    }
    
    private Unit assemble(Board b, Sensor s1, Sensor s2) {
        //return ModuleFactory.createModule(b, s1, s2);
        return null;
    }
    
    public void setState(State s) { state = s; }
    
    public State getState() { return state; }
    
    public void write (CorsoData data) throws CorsoDataException {
        data.putStructTag ("Module", 1);
        //data.putShareable(staffOid);
        /*data.putShareable(boardOid);
        data.putShareable(sensorOneOid);
        data.putShareable(sensorTwoOid);*/
        
    }
    public void read (CorsoData data) throws CorsoDataException {
        StringBuffer structName = new StringBuffer ();
        int arity = data.getStructTag (structName);
        if (arity != 1 || !structName.toString().equals("Module"))
            throw new CorsoDataException ();
        
        //data.getShareable(staffOid);
        
    }
    
}
